package com.hjy.springbootinit.config;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @version 1.0
 * @Author HJY_Maker
 * @Date 2024/9/10 星期二 21:21
 */
@Component
public class CaffeineConfig {
    @Bean
    public static Cache<String, String> newCaffeineCash(){
        Cache<String, String> cache = Caffeine.newBuilder()
                .expireAfterWrite(10, TimeUnit.MINUTES)
                .maximumSize(10_000)
                .build();
        return cache;
    }

}
